package icu.feigroup.domain.tag.service;

import icu.feigroup.domain.tag.adapter.repository.ITagRepository;
import icu.feigroup.domain.tag.model.entity.CrowdTagsJobEntity;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * projectName:icu.feigroup.domain.tag.service
 *
 * @author 飞
 * @since 2025/2/20 22:13
 * description:
 */
@Service
public class ITagServiceImpl implements ITagService{
    //防止service层与数据库直接交互
    @Resource
    private ITagRepository repository;
    @Override
    public void execTagBatchJob(String tagId, String batchId) {
        CrowdTagsJobEntity crowdTagsJobEntity = repository.queryCrowdTagsJobEntity(tagId, batchId);
        //采集用户数据
        List<String> userList = new ArrayList<String>(){{
            add("fei");
            add("elysia");
            add("fei01");
            add("fei02");
            add("fei03");
            add("fei04");
            add("fei05");
        }};

        for (String userId : userList){
            repository.addCrowdTagsUserId(tagId,userId);
        }

        //更新人群标签统计量
        repository.updateCrowdTagsStatistics(tagId,userList.size());
    }
}
